﻿@{
    ViewData["Title"] = "仓库管理";
}
<div class="box2" panelTitle="检索条件">
    <form id="queryForm" method="post">
        <table formMode="transparent">
            <tr>
                <td>订单号：</td>
                <td><input type="text" name="orderNo" id="orderNo" value="@ViewData["orderNo"]" readonly="readonly" /></td>
                <td>零件号：</td>
                <td><input type="text" name="partNo" id="partNo" /></td>
                <td>简码：</td>
                <td><input type="text" name="partSpec" id="partSpec" /></td>
                <td>箱条码：</td>
                <td><input type="text" name="cartonNo" id="cartonNo" /></td>
                <td><button type="button" onclick="searchHandler()"><span class="icon_find">查询</span></button></td>
                <td><button type="button" onclick="resetSearch()"><span class="icon_reload">重置</span></button></td>
            </tr>
        </table>
    </form>
</div>
<div class="padding_right">
    <div class="basicTab" id="myTab">
        <div name="盘点单明细">
            <div id="maingrid1"></div>
        </div>
        <div name="盘点物料">
            <div id="maingrid2"></div>
        </div>
        <div name="盘点库区">
            <div id="maingrid3"></div>
        </div>
        <div name="盘点库位">
            <div id="maingrid4"></div>
        </div>
        <div name="盘点范围">
            <div id="maingrid5"></div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var grid1; var grid2; var grid3; var grid4; var grid5;
    function initComplete() {

        grid1 = $("#maingrid1").quiGrid({
            columns: [
                { display: '盘点单号', name: 'orderNo', align: 'center', width: 120 },
                { display: '零件号', name: 'partNo', align: 'center', width: 200 },
                { display: '零件号简码', name: 'partSpec', align: 'center', width: 100 },
                { display: '单位', name: 'unit', align: 'center', width: 100 },
                { display: '周转箱条码', name: 'turnoverBoxNo', align: 'center', width: 150 },
                { display: '箱条码', name: 'cartonNo', align: 'center', width: 150 },
                { display: '应盘数量', name: 'qty', align: 'center', width: 100 },
                { display: '实盘数量', name: 'factQty', align: 'center', width: 100 },
                { display: '上一次实盘数量', name: 'upFactQty', align: 'center', width: 120 },
                { display: '应盘库位', name: 'locateName', align: 'center', width: 100 },
                { display: '实盘库位', name: 'destLocateName', align: 'center', width: 100 },
                { display: '上一次实盘数量', name: 'upDestLocateName', align: 'center', width: 120 },
                { display: '应盘库区', name: 'zoneName', align: 'center', width: 100 },
                { display: '实盘库区', name: 'destZoneName', align: 'center', width: 100 },
                { display: '上一次实盘数量', name: 'upDestZoneName', align: 'center', width: 120 },
                { display: '应盘仓库', name: 'warehouseName', align: 'center', width: 100 },
                { display: '实盘仓库', name: 'destWarehouseName', align: 'center', width: 100 },
                { display: '上一次实盘数量', name: 'upDestWarehouseName', align: 'center', width: 120 },
                { display: '条码状态', name: 'snStatusDesc', align: 'center', width: 100 },
                { display: '事务状态', name: 'transStatusDesc', align: 'center', width: 100 },
                { display: '上一次事务状态', name: 'upTransStatusDesc', align: 'center', width: 120 },
                { display: '工厂代码', name: 'factoryCode', align: 'center', width: "200%" }
            ],
            alternatingRow: false,
            rowAttrRender: function(rowdata, rowid) {
                if (10 == rowdata.transStatus) {
                    return "style=\"background-color:#74F8FA;\"";
                }
                else if (20 == rowdata.transStatus) {
                    return "style=\"background-color:#21F82B;\"";
                }
                else if (30 == rowdata.transStatus) {
                    return "style=\"background-color:#F0292B;\"";
                }
                else if (40 == rowdata.transStatus) {
                    return "style=\"background-color:#F0CF2B;\"";
                }
                else if (50 == rowdata.transStatus) {
                    return "style=\"background-color:#548AE3;\"";
                }
                else if (60 == rowdata.transStatus) {
                    return "style=\"background-color:#F0A5FA;\"";
                }
            },
            data: [], sortName: 'orderNo', rownumbers: true, checkbox: true,
            height: '100%', width: "100%", percentWidthMode: true, pageSize: 100
        });
        $.post("/wms/CycleCountManage/getCheckStockListByPage",
            {
                "orderNo": $("#orderNo").val()
            },
            function(result) {
                grid1.loadData(result);
            }, "json");

        grid2 = $("#maingrid2").quiGrid({
            columns: [
                { display: '盘点单号', name: 'orderNo', align: 'center', width: "10%" },
                { display: '零件号', name: 'partNo', align: 'center', width: "10%" },
                { display: '零件号名称', name: 'partSpec', align: 'center', width: "10%" },
                { display: '工厂代码', name: 'factoryCode', align: 'center', width: "10%" }
            ],
            data: [], sortName: 'orderNo', rownumbers: true, checkbox: true,
            height: '100%', width: "100%", percentWidthMode: true, pageSize: 100
        });
        $.post("/wms/CycleCountManage/getCheckStockPartByPage",
            {
                "orderNo": $("#orderNo").val()
            },
            function(result) {
                grid2.loadData(result);
            }, "json");

        grid3 = $("#maingrid3").quiGrid({
            columns: [
                { display: '盘点单号', name: 'orderNo', align: 'center', width: "10%" },
                { display: '库区名称', name: 'zoneName', align: 'center', width: "10%" },
                { display: '工厂代码', name: 'factoryCode', align: 'center', width: "10%" }
            ],
            data: [], sortName: 'orderNo', rownumbers: true, checkbox: true,
            height: '100%', width: "100%", percentWidthMode: true, pageSize: 100
        });
        $.post("/wms/CycleCountManage/getCheckStockZoneByPage",
            {
                "orderNo": $("#orderNo").val()
            },
            function(result) {
                grid3.loadData(result);
            }, "json");

        grid4 = $("#maingrid4").quiGrid({
            columns: [
                { display: '盘点单号', name: 'orderNo', align: 'center', width: "10%" },
                { display: '库位名称', name: 'locateName', align: 'center', width: "10%" },
                { display: '工厂代码', name: 'factoryCode', align: 'center', width: "10%" }
            ],
            data: [], sortName: 'orderNo', rownumbers: true, checkbox: true,
            height: '100%', width: "100%", percentWidthMode: true, pageSize: 100
        });
        $.post("/wms/CycleCountManage/getCheckStockLocateByPage",
            {
                "orderNo": $("#orderNo").val()
            },
            function(result) {
                grid4.loadData(result);
            }, "json");

        grid5 = $("#maingrid5").quiGrid({
            columns: [
                { display: '盘点单号', name: 'orderNo', align: 'center', width: "10%" },
                { display: '库区名称', name: 'zoneName', align: 'center', width: "10%" },
                { display: '库位名称', name: 'locateName', align: 'center', width: "10%" },
                { display: '零件号', name: 'partNo', align: 'center', width: "10%" },
                { display: '零件号名称', name: 'partSpec', align: 'center', width: "10%" },
                { display: '工厂代码', name: 'factoryCode', align: 'center', width: "10%" },
            ],
            data: [], sortName: 'orderNo', rownumbers: true, checkbox: true,
            height: '100%', width: "100%", percentWidthMode: true, pageSize: 100
        });
        $.post("/wms/CycleCountManage/getCheckStockRangeByPage",
            {
                "orderNo": $("#orderNo").val()
            },
            function(result) {
                grid5.loadData(result);
            }, "json");




        $("#myTab").bind("actived", function(e, idx) {
            if (idx == 0) {
                grid1.resetHeight();
                grid1.resetWidth();
            }
            else if (idx == 1) {
                grid2.resetHeight();
                grid2.resetWidth();
            }
            else if (idx == 2) {
                grid3.resetHeight();
                grid3.resetWidth();
            }
            else if (idx == 3) {
                grid4.resetHeight();
                grid4.resetWidth();
            }
            else if (idx == 4) {
                grid5.resetHeight();
                grid5.resetWidth();
            }
        })
    }

    //查询
    function searchHandler() {
        //得到查询参数
        var query = $("#queryForm").formToArray();

        $.post("/wms/CycleCountManage/getSearchCheckStockList",
            query,
            function(result) {
                grid1.loadData(result);
            }, "json");

        //页号重置为1
        grid.setNewPage(1);
        //重新加载数据
        grid.loadData();
    }

    //重置查询
    function resetSearch() {
        $("#queryForm")[0].reset();
        searchHandler();
    }

    //刷新表格 表单提交的回调
    function afterFormSubmit() {
        grid1.loadData();

        grid2.loadData();
        grid3.loadData();
    }

    //刷新表格数据并重置排序和页数
    function refresh(isUpdate) {
        if (!isUpdate) {
            //重置排序
            grid1.options.sortName = 'orderNo';
            grid1.options.sortOrder = "desc";
            //页号重置为1
            grid1.setNewPage(1);
        }

        grid1.setNewPage(1);
        //重新加载数据
        grid1.loadData();

        grid2.setNewPage(1);
        //重新加载数据
        grid2.loadData();

        grid3.setNewPage(1);
        //重新加载数据
        grid3.loadData();

        grid4.setNewPage(1);
        //重新加载数据
        grid4.loadData();

        grid5.setNewPage(1);
        //重新加载数据
        grid5.loadData();

    }

</script>	